<?php

/**
 * This is the model class for table "{{cash}}".
 *
 * The followings are the available columns in table '{{cash}}':
 * @property string $zch_id
 * @property integer $zm_id
 * @property double $zch_price
 * @property string $zch_account
 * @property integer $zch_type
 * @property string $zch_username
 * @property string $zch_user_bank
 * @property string $zch_bank
 * @property string $zch_back_no
 * @property integer $zch_status
 * @property string $zch_re
 * @property integer $inputtime
 */
class Cash extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Cash the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{cash}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zm_id, zch_type, zch_status, inputtime', 'numerical', 'integerOnly'=>true),
			array('zch_price', 'numerical'),
			array('zch_id, zch_account, zch_username, zch_user_bank, zch_bank', 'length', 'max'=>255),
			array('zch_back_no', 'length', 'max'=>50),
			array('zch_re', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('zch_id, zm_id, zch_price, zch_account, zch_type, zch_username, zch_user_bank, zch_bank, zch_back_no, zch_status, zch_re, inputtime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'zch_id' => 'Zch',
			'zm_id' => 'Zm',
			'zch_price' => 'Zch Price',
			'zch_account' => 'Zch Account',
			'zch_type' => 'Zch Type',
			'zch_username' => 'Zch Username',
			'zch_user_bank' => 'Zch User Bank',
			'zch_bank' => 'Zch Bank',
			'zch_back_no' => 'Zch Back No',
			'zch_status' => 'Zch Status',
			'zch_re' => 'Zch Re',
			'inputtime' => 'Inputtime',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('zch_id',$this->zch_id,true);
		$criteria->compare('zm_id',$this->zm_id);
		$criteria->compare('zch_price',$this->zch_price);
		$criteria->compare('zch_account',$this->zch_account,true);
		$criteria->compare('zch_type',$this->zch_type);
		$criteria->compare('zch_username',$this->zch_username,true);
		$criteria->compare('zch_user_bank',$this->zch_user_bank,true);
		$criteria->compare('zch_bank',$this->zch_bank,true);
		$criteria->compare('zch_back_no',$this->zch_back_no,true);
		$criteria->compare('zch_status',$this->zch_status);
		$criteria->compare('zch_re',$this->zch_re,true);
		$criteria->compare('inputtime',$this->inputtime);

		$criteria->order = " inputtime DESC ";//默认为时间倒序
		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}